<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" type="text/css" href="../../../Themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../../Themes/icon.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/demo.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/common.css">
		<script type="text/javascript" src="../../../JS/jquery.min.js"></script>
		<script type="text/javascript" src="../../../JS/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="../../../JS/common.js"></script>
		<script type="text/javascript" src="../../../JS/SHA-1.js"></script>
	</head>

	<body style="padding: 0px;">
		<div class="easyui-layout" style="width:100%;height:500px;">
			<div data-options="region:'center'">
				<div>
					<table id="dg" title="销售结算单" width="100%">
					</table>
				</div>
			</div>
		</div>
		<div id="toolbar"></div>
		<div id="dlg" class="hiddenDialog">
			<iframe id="ifrmEdit" style="width: 100%;height: 100%;" frameborder="0" scrolling="no"></iframe>
		</div>
	</body>
	<script>
		var currid = getID(); /**得到当前界面的ID**/
		var content = ""; /*定义一个空的content*/
		var AddDialog;
		content = AddToolBar(43); /**根据用户的权限，来决定生成ToolBar的哪些功能**/
		$("#toolbar").append(content); /*在ID=toolbar的标记后面添加content中的内容*/
		function newdata() {
			var pLocation = "";
			pLocation = "UI/LOGISTICS/SalesSettlementOrderCreate/SalesSettlementOrderCreateSearch.html?"; /*将BoothManagementAdd.html的相对路径与被选中行的ID赋值给pLocation*/
			AddTabIn("新建销售结算", parent.parent.$("#tabs"), pLocation);
		}

		function print() {
			var row = $('#dg').datagrid('getSelections');
			if(row.length == 0) {
				$.messager.alert('Info', "没有选中");
				return;
			}
			var selectedID = "";
			for(var i = 0; i < row.length; i++) {
				selectedID = selectedID + row[i].ID + ";";
			}
			var pLocation = "SalesSettlementPrint.html?id=" + selectedID;
			window.open(pLocation); /*打开pLocation中的链接html文档*/
		}

		function editdata() {
			var row = $("#dg").datagrid("getSelected");
			if(!row) {
				$.messager.alert("警告", "请选中数据");
			} else {
				var pLocation = "";
				pLocation = "UI/LOGISTICS/SalesSettlementOrder/SalesSettlementAdd.html?id=" + row.ID; /*将BoothManagementAdd.html的相对路径与被选中行的ID赋值给pLocation*/
				AddTabIn("销售结算明细", parent.parent.$("#tabs"), pLocation);
			}
		}
		$('#dg').datagrid({
			url: RemoteLinkAddress + '/logistics/receiveorder/list.do',
			toolbar: '#toolbar',
			method: 'get',
			pagination: 'true',
			rownumbers: 'true',
			autoRowHeight: 'true',
			fitColumns: 'false',
			height: 350,
			/*表格中的列名以及各自列名的ID*/
			columns: [
				[{
					field: 'ck',
					checkbox: 'true',
				}, {
					field: 'ID',
					title: 'ID',
					width: '0%'
				}, {
					field: 'ORDER_NO',
					title: '编号',
					width: '14%',
					align: 'center'
				}, {
					field: 'SALESORDER_NO',
					title: '销售单编号',
					width: '14%',
					align: 'center'
				}, {
					field: 'CUSTOMER_TYPE',
					title: '用户组',
					width: '14%',
					align: 'center'
				}, {
					field: 'CUSTOMER_NAME',
					title: '配送单位',
					width: '14%',
					align: 'center'
				}, {
					field: 'DISTRIBUTION_DATE',
					title: '配送时间',
					width: '10%',
					align: 'center'
				}, {
					field: 'CREATE_TIME',
					title: '建单时间',
					width: '10%',
					align: 'center'
				}, {
					field: 'ISVERIFY',
					title: '审核状态',
					width: '12%',
					align: 'center',
					formatter: function(value, row, index) {
						return verifyStatus(value, false);
					}
				}, ]
			],
			onDblClickRow: function(index, row) {
				var pLocation = "";
				pLocation = "UI/LOGISTICS/SalesSettlementOrder/SalesSettlementAdd.html?id=" + row.ID; /*将BoothManagementAdd.html的相对路径与被选中行的ID赋值给pLocation*/
				AddTabIn("销售结算明细", parent.parent.$("#tabs"), pLocation);
				console.log(pLocation);
			}
		});
		$('#dg').datagrid('hideColumn', 'ID');

		function redodata() {
			var _url = RemoteLinkAddress + '/logistics/receiveorder/list.do';
			$.ajax({
				dataType: "json",
				type: "get",
				url: _url,
				success: function(result) {
					if(result != null) {
						var _data = result;
						$('#dg').datagrid('loadData', _data);
					}
				},
				error: function(xhr, status, error) {
					$.messager.alert("错误", "请求失败!");
				}
			});
		}
	</script>

</html>